package team119;

import java.util.Comparator;

import battlecode.common.MapLocation;

public class MapLocationDistanceToEnemyHQComparator implements Comparator<MapLocation>
{
	MapLocation _enemyHQ;
	
	public MapLocationDistanceToEnemyHQComparator(MapLocation enemy) {
		_enemyHQ = enemy;
	}
	
    @Override
    public int compare(MapLocation x, MapLocation y)
    {
        // Assume neither string is null. Real code should
        // probably be more robust
        if (x.distanceSquaredTo(_enemyHQ) < y.distanceSquaredTo(_enemyHQ))
        {
            return 1;
        }
        if (x.distanceSquaredTo(_enemyHQ) > y.distanceSquaredTo(_enemyHQ))
        {
            return -1;
        }
        return 0;
    }
}